<?php
/**
 * Created by PhpStorm.
 * User: sunshine
 * Date: 2016/8/31
 * Time: 8:46
 */
require_once "Admin/Controller/Controller.php";
require_once "Admin/Model/PainfoModel.php";

class PainfoController extends Controller
{
    function __Construct(){
        parent::__Construct();

    }
    function painfolist(){
        if (isset($_SESSION['admin'])) {
            $model = new PainfoModel();
            $data = $model->getPainfoList();
            $this->assign('painfo', $data);
            $this->display();
        }
    }

    function form(){
        if (isset($_SESSION['admin']))
        $this->display();
    }
    function add(){
        if (isset($_SESSION['admin'])){
        $data=$_POST;
        $model = new PainfoModel();
        $result = $model->addPainfo($data);
        if($result){
            echo '添加成功 <a href="admin.php?c=painfo&m=painfolist">如果没有跳转，请点这里跳转</a>';
            header("refresh:3;url='admin.php?c=painfo&m=painfolist'");
        }
        else{
            echo "添加失败！<br/>";
            header("refresh:3;url='admin.php?c=painfo&m=painfolist'");
        }
    }}

}
?>